/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.client.modular.event;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.goods.param.ClientCheckGoodsCheckItemsParam;
import vip.xiaonuo.biz.modular.goods.param.ClientGoodsCheckParam;
import vip.xiaonuo.biz.modular.goods.param.ClientUserBorrowPageParam;
import vip.xiaonuo.biz.modular.goods.result.ClientGoodsCheckItemResult;
import vip.xiaonuo.biz.modular.goods.result.ClientUserBorrowPageResult;
import vip.xiaonuo.biz.modular.goods.service.BizGoodsCheckService;
import vip.xiaonuo.biz.modular.goods.service.BizGoodsLedgerCheckService;
import vip.xiaonuo.biz.modular.goods.service.BizGoodsLedgerService;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author kongxm
 * @date 2022/11/20 17:04
 */
@Api(tags = "用户-借用记录")
@RestController
@Validated
public class ClientUserBorrowController {
    @Resource
    private BizGoodsLedgerService bizGoodsLedgerService;
    @Resource
    private BizGoodsCheckService bizGoodsCheckService;
    @Resource
    private BizGoodsLedgerCheckService bizGoodsLedgerCheckService;

    /**
     * @author kongxm
     * @date 2022/11/20 17:04
     */
    @ApiOperationSupport
    @ApiOperation("我的借用列表（分页）")
    @PostMapping("/client/userborrow/page")
    public CommonResult<Page<ClientUserBorrowPageResult>> pageUserBorrowRecords(@RequestBody ClientUserBorrowPageParam param) {
        return CommonResult.data(bizGoodsLedgerService.pageClientUserBorrowRecords(param));
    }

    /**
     * @author kongxm
     * @date 2022/11/20 17:04
     */
    @ApiOperationSupport
    @ApiOperation("借用(归还)检查列表")
    @GetMapping("/client/goodscheckitem/list")
    public CommonResult<List<ClientGoodsCheckItemResult>> listClientGoodsCheckItems(ClientGoodsCheckParam param) {
        return CommonResult.data(bizGoodsCheckService.listClientGoodsCheckItems(param));
    }

    /**
     * @author kongxm
     * @date 2022/11/20 17:04
     */
    @ApiOperationSupport
    @ApiOperation("借用(归还)检查")
    @PostMapping("/client/goodscheckitem/check")
    public CommonResult<String> checkGoodsCheckItemForClient(@RequestBody ClientCheckGoodsCheckItemsParam param) {
        bizGoodsLedgerCheckService.checkGoodsCheckItemForClient(param);
        return CommonResult.ok();
    }
}
